function S = find_dup(C)
%%This program will take in S3DB reply from s3db_read and remove all the
%%duplicates found in the first column so that they can be used to create a
%%structure. Else the structure will fail since it cannot have duplicate
%%keys. Basically it will append '_digits' to the second and more duplicats
%%it finds. The digits are random numbers.
%%
%% ROmesh Stanislaus April 2010


for i = 1:size(C,1)
    %z=regexp(C(:,1), ['^',C{i,1}]);
    z=regexp(C(:,1), ['^',C{i,1},'$']); %match front and back
    dupNum=0;
    for h=1:length(z)
        if not(isempty(z{h}))
            dupNum =dupNum +1;
            if dupNum >= 2
                %that means there are duplicatted change name
                %m = regexprep(num2str(rand()),'0.','');
                C{h,1}=[C{h,1},'_',regexprep(num2str(rand()),'0.','')];
            end
        end
    end
end
S=C;